"""
    Controller for discont dictionary table.
"""

from mnemoply import model
from mnemoply.controllers.lookup import LookupController, TableCol, TableLookupDataSource
from mnemoply.controllers.crud import CRUDController

class DiscontController(LookupController, CRUDController):
    model_object = model.Discont
    lookup_columns = [
        TableCol(name='name', caption=_('Name')),
        TableCol(name='amount', caption=_('Discont in rubles')),
        TableCol(name='percent', caption=_('Discont in percent')),
        TableCol(name='is_percent_str', caption=_('Is percent?')),
        TableCol(name='is_active_str', caption=_('Is active?')),
        TableCol(name='comment', caption=_('Comment'), hidden=True),
    ]
    view_fields = ['name', 'amount', 'percent', 'isPercent', 'isActive', 'comment']

    def __init__(self):
        LookupController.__init__(self,
            data_source=TableLookupDataSource('discont_lookup'),
            columns=self.lookup_columns,
            title=self.model_object.model_title,
        )
        CRUDController.__init__(self, model_object=self.model_object)

exposed = DiscontController()
